import {createRouter, createWebHistory} from 'vue-router'

import PromptHome from '@/views/home/PromptHome.vue'

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/',
            name: 'PromptHome',
            component: PromptHome,
            meta: {
                title: '欢迎使用逐雁排程'
            },
        },
        {
            path: "/ope",
            component: () => import("@/layout/index.vue"),
            redirect: "/view-rota",
            meta: {title: '逐雁排程——操作'},
            children: [
                {
                    path: '/generate-key',
                    name: 'GenerateKey',
                    component: () => import('@/views/admin/indexAdminkey.vue'),
                    meta: {
                        title: '逐雁排程——生成密钥',
                        prompt: '生成一个上传课程表连接，然后分享给你的朋友'

                    },
                },
                {
                    path: '/upload-course/:userId',
                    name: 'UploadCourseSchedule',
                    component: () => import('@/views/timetable/indexTimeTable.vue'),
                    meta: {
                        title: '逐雁排程——上传课程表',
                        prompt: '以图片的形式上传课程表'
                    },
                },
                {
                    path: '/Update-Course',
                    name: 'UpdateCourseSchedule',
                    component: () => import('@/views/timetable/updateTimeTable.vue'),
                    meta: {
                        title: '逐雁排程——查看/修改课程表',
                        prompt: '查看或者修改你的课程表'

                    },
                },
                {
                    path: '/upload-table/:userId',
                    name: 'UploadTableSchedule',
                    component: () => import('@/views/timetable/uploadTable.vue'),
                    meta: {
                        title: '逐雁排程——上传课程表',
                        prompt: '以表格的形式上传课程表'
                    },
                },
                {
                    path: '/view-rota',
                    name: 'ViewRota',
                    component: () => import('@/views/rota/indexRota.vue'),
                    meta: {
                        title: '逐雁排程——查看值班表',
                        prompt: '查看值班表，如果你是管理员的话还可以修改值班表。'

                    },
                },
                {
                    path: '/manage-rota',
                    name: 'ManageRota',
                    component: () => import('@/views/admin/indexManageRota.vue'),
                    meta: {
                        title: '逐雁排程——管理值班表',
                        prompt: '管理值班表，可以修改值班表，也可以删除值班表。'

                    },
                }
            ]
        }
    ]
})
router.beforeEach((to, from, next) => {
    document.title = to.meta.title || "逐雁排程"
    next()
})

export default router
